class Solution(object):
    def convertToBase7(self, num):
        """
        :type num: int
        :rtype: str
        """
        flag = 0
        if num < 0:
            flag = 1
            num = - num
        s = ''
        while num // 7 > 0:
            s += str(num % 7)
            num = num // 7
        s += str(num % 7)
        if not flag:
            return s[::-1]
        else:
            return '-' + s[::-1]